Skip to content

fix: cloudwatch logs fetch logic#20814

Merged
potiuk merged 1 commit intoapache:mainfrom
ayushchauhan0811:fix/aws_cw_logs
Jan 23, 2022
Merged

fix: cloudwatch logs fetch logic#20814
potiuk merged 1 commit intoapache:mainfrom
ayushchauhan0811:fix/aws_cw_logs

Conversation

@ayushchauhan0811
Copy link
Copy Markdown
Contributor

Cloudwatch get_log_events can return empty results even though there are more log events available in the stream. In my recent interaction with the AWS team, it was pointed out that the correct way to check for end of stream is that if the value of nextForwardToken is same in subsequent calls

https://docs.aws.amazon.com/AmazonCloudWatchLogs/latest/APIReference/API_GetLogEvents.html

@boring-cyborg boring-cyborg bot added area:providers provider:amazon AWS/Amazon - related issues labels Jan 11, 2022
yield from events

if 'nextForwardToken' in response:
if next_token != response['nextForwardToken']:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we use response.get('nextForwardToken', None) to avoid any chance of a KeyError here, or do we know for sure that will always be included in the response?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably OK to just fail if the response format changes. An exception raised here (assuming the hook is used in a DAG) would eventually be caught by the test runner and logged to the task logs, which would clearly signal the problem (the API has an unexpected change in format). If we silently fall back to None, it would be more difficult to debug later if the API changed format unexpected (missing nextForwardToken), or actually returned "nextForwardToken": null (which is expected and signals a valid scenario, indicating we or the user may have logical bugs in the workflow).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ferruzzi @uranusjr Is there any change required in this PR or is it good to go?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uranusjr covered my concern, but I'm also not a committer so my approval doesn't carry much (any) weight.

@github-actions
Copy link
Copy Markdown

The PR is likely OK to be merged with just subset of tests for default Python and Database versions without running the full matrix of tests, because it does not modify the core of Airflow. If the committers decide that the full tests matrix is needed, they will add the label 'full tests needed'. Then you should rebase to the latest main or amend the last commit of the PR, and push it with --force-with-lease.

@github-actions github-actions bot added the okay to merge It's ok to merge this PR as it does not require more tests label Jan 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:providers okay to merge It's ok to merge this PR as it does not require more tests provider:amazon AWS/Amazon - related issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants